package me.zhengjie.minbearwcs.dao.outbound.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.RequiredArgsConstructor;
import me.zhengjie.minbearwcs.dao.outbound.inf.SortPalletDetailDao;
import me.zhengjie.minbearwcs.entity.Mapper.outbound.SortPalletDetailMapper;
import me.zhengjie.minbearwcs.entity.PO.wcs.outbound.sort.SortPalletDetail;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@RequiredArgsConstructor
public class SortPalletDetailDaoImpl implements SortPalletDetailDao {

    private final SortPalletDetailMapper mapper;

    @Override
    public boolean insert(SortPalletDetail sortPalletDetail) {
        return mapper.insert(sortPalletDetail) == 1;
    }

    @Override
    public List<SortPalletDetail> selectByPalletCode(String palletCode) {
        return new LambdaQueryChainWrapper<>(mapper)
                .eq(SortPalletDetail::getPalletCode, palletCode)
                .list();
    }

    @Override
    public List<SortPalletDetail> selectByOutboundOrderCode(String outboundOrderCode) {
        return new LambdaQueryChainWrapper<>(mapper)
                .eq(SortPalletDetail::getOutboundOrderCode, outboundOrderCode)
                .list();
    }

    @Override
    public boolean deletaById(Integer id) {
        return mapper.deleteById(id) == 1;
    }
}
